package com.cxria.script.upload.domain;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "transcodeInfo")
class TranscodeInfo implements Serializable {
    @Id
    @ManyToOne
    @JsonBackReference
    @JoinColumn(name = "videoId")
    Video video;
    @Column
    //@ApiModelProperty("容器格式")
    String format;
    @Column
    //@ApiModelProperty("视频编解解码器")
    String videoCodec;
    @Column
    //@ApiModelProperty("视频像素格式")
    String pixelFormat;
    @Column
    //@ApiModelProperty("视频质量指数")
    double crf;
    @Column
    //@ApiModelProperty("视频是否转码出sdr版本")
    boolean addSdr;
    @Column
    //@ApiModelProperty("音频编解码器")
    String audioCodec;
    @Column
    //@ApiModelProperty("音频采样格式")
    String sampleFormat;
    @Column
    //@ApiModelProperty("字幕编解码器")
    String subtitleCodec;

    @Override
    boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TranscodeInfo that = (TranscodeInfo) o;
        return Double.compare(that.crf, crf) == 0 &&
                addSdr == that.addSdr &&
                Objects.equals(video, that.video) &&
                Objects.equals(format, that.format) &&
                Objects.equals(videoCodec, that.videoCodec) &&
                Objects.equals(pixelFormat, that.pixelFormat) &&
                Objects.equals(audioCodec, that.audioCodec) &&
                Objects.equals(sampleFormat, that.sampleFormat) &&
                Objects.equals(subtitleCodec, that.subtitleCodec);
    }

    @Override
    int hashCode() {
        return Objects.hash(video, format, videoCodec, pixelFormat, crf, addSdr, audioCodec, sampleFormat, subtitleCodec);
    }
}
